/*$(".password").on("click", ".fa-eye-slash", function () {
    $(this).removeClass("fa-eye-slash").addClass("fa-eye");
    $(this).prev().attr("type", "text");
});

$(".password").on("click", ".fa-eye", function () {
    $(this).removeClass("fa-eye").addClass("fa-eye-slash");
    $(this).prev().attr("type", "password");
});*/

$(document).on('click','#login_btn',function() {

    var username = $('#username').val();
    var password = $('#password').val();
    if(username==""){
        new $.zui.Messager('用户名不能为空', {
            type:'danger',
            time:'3000',
            icon: 'heart',
            placement: 'bottom' // 定义显示位置
        }).show();
        window. event.returnValue=false;
        return;
    } else if(password==""){
        new $.zui.Messager('密码不能为空', {
            type:'danger',
            time:'3000',
            icon: 'heart',
            placement: 'bottom' // 定义显示位置
        }).show();
        window.event.returnValue=false;
        return;
    }else {
        var opts = {
            method: 'post',
            url: dataUrl.util.adminLogin(),
            data: "userName=" + username + "&pwd=" + password,
            contentType: 'application/x-www-form-urlencoded; charset=utf-8',
            dataType: 'json',
            success: function (res) {

                if (res.code == '8888') {
                    //存入cooke中获取用户名密码
                    var checked = $("#remeberUserInfo").prop("checked");
                    if(checked){
                        $.cookie("rmbUser", "true", { expires: 90 }); //存储一个带7天期限的cookie
                        $.cookie("username", username, { expires: 90 });
                        $.cookie("password", password, { expires: 90 });
                    }
                    window.location.href = 'subscribeAdmin.html';
                    window.event.returnValue = false;
                } else {

                    new $.zui.Messager(res.msg, {
                        type: 'danger',
                        time: '3000',
                        icon: 'heart',
                        placement: 'bottom' // 定义显示位置
                    }).show();
                    window.event.returnValue=false;
                }
            }
        };
        sysAjax(opts);
    }
});

$(function(){
    var checked = $("#remeberUserInfo").prop("checked");
    if(checked){
        //从cooke中获取用户名密码
       var userName =  $.cookie("username");
       var password = $.cookie("password");
        $('#username').val(userName);
        $('#password').val(password);
    }
});